#!/bin/bash

xsd2cpp -s ccExtAny.xsd .  && ./autogen.sh &&  make install
if [ $? -ne 0 ]; then
  echo "   failed to build in dir: `pwd`"
  exit 1
fi

# TEST
run=./build/bin/ccExtAnyrun

$run -s 
# check sample.xml exists
if [ ! -f sample.xml ]; then
  echo "   sample.xml doesn't exist"
  exit 1  
fi

$run -w 
# check t.xml exists
if [ ! -f t.xml ]; then
  echo "   t.xml doesn't exist"
  exit 1  
fi

# validate
$run -w && $run -v valid.xml 
if [ $? -ne 0 ]; then
  echo "   test failed in dir: `pwd`"
  exit 1  
fi

# rountrip
$run -r ./valid.xml >> tests.log 2>&1
if [ ! -f valid.xml.rt.xml ]; then
  echo "  valid.xml.rt.xml doesn't exist"
  exit 1  
fi

